#include "item.h"
#include"base.h"
#include"enemyplane.h"
#include<QRandomGenerator>
item::item()
{
    int a= QRandomGenerator::global()->bounded(5);
    switch (a)
    {
    case 2:
    case 4:
        m_item.load(ITEM1);
        item_code=1;
        break;
    case 3:
         m_item.load(ENEMYPATH3);
         item_code=2;
         break;
    default:
        m_item.load(ITEM2);
        item_code=3;
        break;
    }
    m_X = 0;
    m_Y = 0;
    m_Free = true;
    m_Speed = ITEM_SPEED;
    m_Rect.setWidth(m_item.width());
    m_Rect.setHeight(m_item.height());
    m_Rect.moveTo(m_X,m_Y);
}
void item::updatePosition()
{
    //空闲状态，不计算坐标
    if(m_Free) { return; }
    m_Y += m_Speed;
    m_Rect.moveTo(m_X,m_Y);

}
void item::reload()
{
 int a= QRandomGenerator::global()->bounded(5);
switch (a)
{
case 2:
case 4:
    m_item.load(ITEM1);
    item_code=1;
    break;
case 3:
     m_item.load(ITEM3);
     item_code=2;
     break;
default:
    m_item.load(ITEM2);
    item_code=3;
    break;
}
}
